import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: () => import('@/views/login.vue')
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: () => import('@/views/error-page/500.vue')
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: () => import('@/views/form/article-publish/preview.vue')
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        { path: 'home', title: {i18n: 'home'}, name: 'home_index', component: () => import('@/views/home/home.vue') },
        { path: '/product/edit', title: '商品编辑', name: 'product_edit', component: resolve => { require(['@/views/product/edit.vue'], resolve); } },
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/user',
        icon: 'android-person',
        name: 'user',
        access: 0,
        title: '会员管理',
        component: Main,
        children: [
            {
                path: '/user/list',
                icon: 'ios-paper-outline',
                name: 'user_index',
                access: 0,
                title: '普通会员',
                component: () => import('@/views/user/list.vue')
            },
            {
                path: '/user/shop',
                icon: 'ios-paper-outline',
                name: 'user_shop',
                access: 0,
                title: '网店会员',
                component: resolve => { require(['@/views/user/shop.vue'], resolve); }
            },
            {
                path: '/user/offlineshop',
                icon: 'ios-paper-outline',
                name: 'user_offlineshop',
                access: 0,
                title: '实体店',
                component: resolve => { require(['@/views/user/offshop.vue'], resolve); }
            }
        ]
    },
    {
        path: '/order',
        icon: 'cube',
        name: 'order',
        access: 0,
        title: '订单管理',
        component: Main,
        children: [
            {
                path: '/product/order',
                icon: 'social-twitch-outline',
                name: 'order_index',
                access: 0,
                title: '所有订单',
                component: resolve => { require(['@/views/order/order.vue'], resolve); }
            },
            {
                path: '/product/order1',
                icon: 'social-twitch-outline',
                name: 'order1',
                access: 0,
                title: '待发货',
                component: resolve => { require(['@/views/order/order1.vue'], resolve); }
            }
        ]
    },
    {
        path: '/product',
        icon: 'cube',
        name: 'product',
        access: 0,
        title: '商品管理',
        component: Main,
        children: [
            {
                path: '/product/productIndex',
                icon: 'ios-paper-outline',
                name: 'product_index',
                title: '商品列表',
                component: resolve => { require(['@/views/product/list.vue'], resolve); }
            },
            {
                path: '/product/cate',
                icon: 'ios-copy-outline',
                name: 'cate',
                access: 0,
                title: '商品分类',
                component: resolve => { require(['@/views/product/catelist.vue'], resolve); }
            },
            {
                path: '/product/speccats',
                icon: 'ios-copy-outline',
                name: 'speccats',
                access: 0,
                title: '商品规格',
                component: resolve => { require(['@/views/product/specCats.vue'], resolve); }
            },
            {
                path: '/shopProduct/off_purchase_log',
                icon: 'ios-paper-outline',
                name: 'off_purchase_log',
                access: 0,
                title: '采购订单',
                component: resolve => { require(['@/views/product/purchaseLog.vue'], resolve); }
            },
        ]
    },
    {
        path: '/shop_product',
        icon: 'cube',
        name: 'shop_product',
        access: 0,
        title: '商品管理',
        component: Main,
        children: [
            {
                path: '/shopProduct/offlineShopList',
                icon: 'ios-paper-outline',
                name: 'offline_index',
                access: 0,
                title: '店铺商品',
                component: resolve => { require(['@/views/product/offlineShopList.vue'], resolve); }
            },
            {
                path: '/shopProduct/cloud',
                icon: 'ios-paper-outline',
                name: 'cloud',
                access: 0,
                title: '云端商品',
                component: resolve => { require(['@/views/product/cloudList.vue'], resolve); }
            },
            {
                path: '/shopProduct/purchase',
                icon: 'ios-paper-outline',
                name: 'purchase',
                access: 0,
                title: '采购清单',
                component: resolve => { require(['@/views/product/purchase.vue'], resolve); }
            },
            {
                path: '/shopProduct/purchase_log',
                icon: 'ios-paper-outline',
                name: 'purchase_log',
                access: 0,
                title: '采购记录',
                component: resolve => { require(['@/views/product/purchaseLog.vue'], resolve); }
            },
        ]
    },
    {
        path: '/config',
        icon: 'ios-partlysunny',
        name: 'config',
        access: 0,
        title: '运营管理',
        component: Main,
        children: [
            {
                path: '/sys/setting',
                icon: 'ios-pulse-strong',
                name: 'sysconfig',
                title: '运营配置',
                component: resolve => { require(['@/views/setting/sys.vue'], resolve); }
            },
            // {
            //     path: '/sms/setting',
            //     icon: 'ios-paper-outline',
            //     name: 'smsconfig',
            //     title: '',
            //     component: resolve => { require(['@/views/setting/sms.vue'], resolve); }
            // },
            {
                path: '/sys/notice',
                icon: 'android-textsms',
                name: 'notice',
                title: '系统公告',
                component: resolve => { require(['@/views/setting/notice.vue'], resolve); }
            }
        ]
    },
    {
        path: '/reward',
        icon: 'cube',
        name: 'reward',
        access: 0,
        title: '我的奖励',
        component: Main,
        children: [
            {
                path: '/reward/withdraw',
                icon: 'ios-paper-outline',
                name: 'reward_draw',
                access: 0,
                title: '积分提现',
                component: resolve => { require(['@/views/reward/withdraw.vue'], resolve); }
            },
            {
                path: '/reward/detail',
                icon: 'ios-paper-outline',
                name: 'reward_detail',
                access: 0,
                title: '奖励明细',
                component: resolve => { require(['@/views/reward/detail.vue'], resolve); }
            },
            {
                path: '/reward/kpi',
                icon: 'ios-paper-outline',
                name: 'reward_kpi',
                access: 0,
                title: '我的业绩',
                component: resolve => { require(['@/views/reward/kpi.vue'], resolve); }
            },
            {
                path: '/reward/kpilog',
                icon: 'ios-paper-outline',
                name: 'reward_kpilog',
                access: 0,
                title: '出入账记录',
                component: resolve => { require(['@/views/reward/kpilog.vue'], resolve); }
            },
            {
                path: '/reward/bank',
                icon: 'ios-paper-outline',
                name: 'bank',
                access: 0,
                title: '收款银行卡',
                component: resolve => { require(['@/views/reward/bank.vue'], resolve); }
            }
        ]
    },
    {
        path: '/apply_list',
        icon: 'cube',
        name: 'apply_list',
        access: 0,
        title: '提现申请',
        component: Main,
        children: [
            {
                path: '/kpi_check/check',
                icon: 'ios-paper-outline',
                name: 'kpi_check',
                access: 0,
                title: '提现审核',
                component: resolve => { require(['@/views/reward/checkkpi.vue'], resolve); }
            }
        ]
    },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
